Imports System
Imports System.Data
Imports System.Data.Common
Imports System.Collections.Generic

Public Class ETDC_Tramites
   Implements ICloneable

#Region " Constructores "
   Public Sub New()

   End Sub
#End Region

#Region " Campos "
   Private m_tram_numero As Integer
   Private m_tram_nroalterno As String
   Private m_tram_nrooperacion As Short
   Private m_area_codregistra As String
   Private m_user_codregistra As String
   Private m_tram_fecregistra As Date
   Private m_prio_codigo As Short
   Private m_tram_estado As String
   Private m_tram_origen As Boolean
   Private m_tipd_codigo As Short
   Private m_tram_seriedoc As String
   Private m_tram_numdoc As String
   Private m_tram_fecemidoc As Nullable(Of Date)
   Private m_tipe_codremitente As String
   Private m_entc_codremitente As String
   Private m_plan_codigo As Nullable(Of Short)
   Private m_tram_asunto As String
   Private m_tipo_tabmnd As String
   Private m_tipo_codmnd As String
   Private m_tram_baseimponible As Decimal
   Private m_tram_basenoafecta As Decimal
   Private m_tram_imp1 As Decimal
   Private m_tram_imp2 As Decimal
   Private m_tram_imp3 As Decimal
   Private m_tram_imp4 As Decimal
   Private m_tram_total As Decimal
   Private m_audi_usrcrea As String
   Private m_audi_feccrea As Date
   Private m_audi_usrmod As String
   Private m_audi_fecmod As Nullable(Of Date)
   Private m_nuevo As Boolean
   Private m_modificado As Boolean
   Private m_eliminado As Boolean
#End Region

#Region " Propiedades "
   Public Property TRAM_Numero() As Integer
      Get
         Return m_tram_numero
      End Get
      Set(ByVal value As Integer)
         If Not IsNothing(m_tram_numero) Then
            If Not m_tram_numero.Equals(value) Then
               m_tram_numero = value
               ActualizarInstancia()
            End If
         Else
            m_tram_numero = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_NroAlterno() As String
      Get
         Return m_tram_nroalterno
      End Get
      Set(ByVal value As String)
         If Not m_tram_nroalterno Is Nothing Then
            If Not m_tram_nroalterno.Equals(value) Then
               m_tram_nroalterno = value
               ActualizarInstancia()
            End If
         Else
            m_tram_nroalterno = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_NroOperacion() As Short
      Get
         Return m_tram_nrooperacion
      End Get
      Set(ByVal value As Short)
         If Not IsNothing(m_tram_nrooperacion) Then
            If Not m_tram_nrooperacion.Equals(value) Then
               m_tram_nrooperacion = value
               ActualizarInstancia()
            End If
         Else
            m_tram_nrooperacion = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property AREA_CodRegistra() As String
      Get
         Return m_area_codregistra
      End Get
      Set(ByVal value As String)
         If Not m_area_codregistra Is Nothing Then
            If Not m_area_codregistra.Equals(value) Then
               m_area_codregistra = value
               ActualizarInstancia()
            End If
         Else
            m_area_codregistra = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property USER_CodRegistra() As String
      Get
         Return m_user_codregistra
      End Get
      Set(ByVal value As String)
         If Not m_user_codregistra Is Nothing Then
            If Not m_user_codregistra.Equals(value) Then
               m_user_codregistra = value
               ActualizarInstancia()
            End If
         Else
            m_user_codregistra = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_FecRegistra() As Date
      Get
         Return m_tram_fecregistra
      End Get
      Set(ByVal value As Date)
         If Not IsNothing(m_tram_fecregistra) Then
            If Not m_tram_fecregistra.Equals(value) Then
               m_tram_fecregistra = value
               ActualizarInstancia()
            End If
         Else
            m_tram_fecregistra = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property PRIO_Codigo() As Short
      Get
         Return m_prio_codigo
      End Get
      Set(ByVal value As Short)
         If Not IsNothing(m_prio_codigo) Then
            If Not m_prio_codigo.Equals(value) Then
               m_prio_codigo = value
               ActualizarInstancia()
            End If
         Else
            m_prio_codigo = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_Estado() As String
      Get
         Return m_tram_estado
      End Get
      Set(ByVal value As String)
         If Not m_tram_estado Is Nothing Then
            If Not m_tram_estado.Equals(value) Then
               m_tram_estado = value
               ActualizarInstancia()
            End If
         Else
            m_tram_estado = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_Origen() As Boolean
      Get
         Return m_tram_origen
      End Get
      Set(ByVal value As Boolean)
         If Not m_tram_origen.Equals(value) Then
            m_tram_origen = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TIPD_Codigo() As Short
      Get
         Return m_tipd_codigo
      End Get
      Set(ByVal value As Short)
         If Not IsNothing(m_tipd_codigo) Then
            If Not m_tipd_codigo.Equals(value) Then
               m_tipd_codigo = value
               ActualizarInstancia()
            End If
         Else
            m_tipd_codigo = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_SerieDoc() As String
      Get
         Return m_tram_seriedoc
      End Get
      Set(ByVal value As String)
         If Not m_tram_seriedoc Is Nothing Then
            If Not m_tram_seriedoc.Equals(value) Then
               m_tram_seriedoc = value
               ActualizarInstancia()
            End If
         Else
            m_tram_seriedoc = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_NumDoc() As String
      Get
         Return m_tram_numdoc
      End Get
      Set(ByVal value As String)
         If Not m_tram_numdoc Is Nothing Then
            If Not m_tram_numdoc.Equals(value) Then
               m_tram_numdoc = value
               ActualizarInstancia()
            End If
         Else
            m_tram_numdoc = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_FecEmiDoc() As Nullable(Of Date)
      Get
         Return m_tram_fecemidoc
      End Get
      Set(ByVal value As Nullable(Of Date))
         If m_tram_fecemidoc.HasValue Then
            If Not m_tram_fecemidoc.Equals(value) Then
               If value.HasValue Then value = CType(value.Value.ToShortDateString(), Date)
               m_tram_fecemidoc = value
               ActualizarInstancia()
            End If
         Else
            If value.HasValue Then value = CType(value.Value.ToShortDateString(), Date)
            m_tram_fecemidoc = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TIPE_CodRemitente() As String
      Get
         Return m_tipe_codremitente
      End Get
      Set(ByVal value As String)
         If Not m_tipe_codremitente Is Nothing Then
            If Not m_tipe_codremitente.Equals(value) Then
               m_tipe_codremitente = value
               ActualizarInstancia()
            End If
         Else
            m_tipe_codremitente = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property ENTC_CodRemitente() As String
      Get
         Return m_entc_codremitente
      End Get
      Set(ByVal value As String)
         If Not m_entc_codremitente Is Nothing Then
            If Not m_entc_codremitente.Equals(value) Then
               m_entc_codremitente = value
               ActualizarInstancia()
            End If
         Else
            m_entc_codremitente = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property PLAN_Codigo() As Nullable(Of Short)
      Get
         Return m_plan_codigo
      End Get
      Set(ByVal value As Nullable(Of Short))
         If m_plan_codigo.HasValue Then
            If Not m_plan_codigo.Equals(value) Then
               m_plan_codigo = value
               ActualizarInstancia()
            End If
         Else
            m_plan_codigo = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_Asunto() As String
      Get
         Return m_tram_asunto
      End Get
      Set(ByVal value As String)
         If Not m_tram_asunto Is Nothing Then
            If Not m_tram_asunto.Equals(value) Then
               m_tram_asunto = value
               ActualizarInstancia()
            End If
         Else
            m_tram_asunto = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TIPO_TabMND() As String
      Get
         Return m_tipo_tabmnd
      End Get
      Set(ByVal value As String)
         If Not m_tipo_tabmnd Is Nothing Then
            If Not m_tipo_tabmnd.Equals(value) Then
               m_tipo_tabmnd = value
               ActualizarInstancia()
            End If
         Else
            m_tipo_tabmnd = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TIPO_CodMND() As String
      Get
         Return m_tipo_codmnd
      End Get
      Set(ByVal value As String)
         If Not m_tipo_codmnd Is Nothing Then
            If Not m_tipo_codmnd.Equals(value) Then
               m_tipo_codmnd = value
               ActualizarInstancia()
            End If
         Else
            m_tipo_codmnd = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_BaseImponible() As Decimal
      Get
         Return m_tram_baseimponible
      End Get
      Set(ByVal value As Decimal)
         If Not IsNothing(m_tram_baseimponible) Then
            If Not m_tram_baseimponible.Equals(value) Then
               m_tram_baseimponible = value
               ActualizarInstancia()
            End If
         Else
            m_tram_baseimponible = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_BaseNoAfecta() As Decimal
      Get
         Return m_tram_basenoafecta
      End Get
      Set(ByVal value As Decimal)
         If Not IsNothing(m_tram_basenoafecta) Then
            If Not m_tram_basenoafecta.Equals(value) Then
               m_tram_basenoafecta = value
               ActualizarInstancia()
            End If
         Else
            m_tram_basenoafecta = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_Imp1() As Decimal
      Get
         Return m_tram_imp1
      End Get
      Set(ByVal value As Decimal)
         If Not IsNothing(m_tram_imp1) Then
            If Not m_tram_imp1.Equals(value) Then
               m_tram_imp1 = value
               ActualizarInstancia()
            End If
         Else
            m_tram_imp1 = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_Imp2() As Decimal
      Get
         Return m_tram_imp2
      End Get
      Set(ByVal value As Decimal)
         If Not IsNothing(m_tram_imp2) Then
            If Not m_tram_imp2.Equals(value) Then
               m_tram_imp2 = value
               ActualizarInstancia()
            End If
         Else
            m_tram_imp2 = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_Imp3() As Decimal
      Get
         Return m_tram_imp3
      End Get
      Set(ByVal value As Decimal)
         If Not IsNothing(m_tram_imp3) Then
            If Not m_tram_imp3.Equals(value) Then
               m_tram_imp3 = value
               ActualizarInstancia()
            End If
         Else
            m_tram_imp3 = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_Imp4() As Decimal
      Get
         Return m_tram_imp4
      End Get
      Set(ByVal value As Decimal)
         If Not IsNothing(m_tram_imp4) Then
            If Not m_tram_imp4.Equals(value) Then
               m_tram_imp4 = value
               ActualizarInstancia()
            End If
         Else
            m_tram_imp4 = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TRAM_Total() As Decimal
      Get
         Return m_tram_total
      End Get
      Set(ByVal value As Decimal)
         If Not IsNothing(m_tram_total) Then
            If Not m_tram_total.Equals(value) Then
               m_tram_total = value
               ActualizarInstancia()
            End If
         Else
            m_tram_total = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property AUDI_UsrCrea() As String
      Get
         Return m_audi_usrcrea
      End Get
      Set(ByVal value As String)
         If Not IsNothing(m_audi_usrcrea) Then
            If Not m_audi_usrcrea.Equals(value) Then
               m_audi_usrcrea = value
               ActualizarInstancia()
            End If
         Else
            m_audi_usrcrea = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property AUDI_FecCrea() As Date
      Get
         Return m_audi_feccrea
      End Get
      Set(ByVal value As Date)
         If Not IsNothing(m_audi_feccrea) Then
            If Not m_audi_feccrea.Equals(value) Then
               m_audi_feccrea = value
               ActualizarInstancia()
            End If
         Else
            m_audi_feccrea = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property AUDI_UsrMod() As String
      Get
         Return m_audi_usrmod
      End Get
      Set(ByVal value As String)
         If Not IsNothing(m_audi_usrmod) Then
            If Not m_audi_usrmod.Equals(value) Then
               m_audi_usrmod = value
               ActualizarInstancia()
            End If
         Else
            m_audi_usrmod = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property AUDI_FecMod() As Nullable(Of Date)
      Get
         Return m_audi_fecmod
      End Get
      Set(ByVal value As Nullable(Of Date))
         If m_audi_fecmod.HasValue Then
            If Not m_audi_fecmod.Equals(value) Then
               m_audi_fecmod = value
               ActualizarInstancia()
            End If
         Else
            m_audi_fecmod = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public ReadOnly Property Nuevo() As Boolean
      Get
         Return m_nuevo
      End Get
   End Property
   Public ReadOnly Property Modificado() As Boolean
      Get
         Return m_modificado
      End Get
   End Property
   Public ReadOnly Property Eliminado() As Boolean
      Get
         Return m_eliminado
      End Get
   End Property
#End Region

#Region " Campos Adicionales "
   Private m_tipd_desc As String
   Private m_tipd_descc As String
   Private m_entc_ruc As String
   Private m_entc_razonsoc As String
   Private m_tram_documento As String
#End Region

#Region " Propiedades Adicionales "
   Public Property TIPD_Desc() As String
      Get
         Return m_tipd_desc
      End Get
      Set(ByVal value As String)
         If Not m_tipd_desc Is Nothing Then
            If Not m_tipd_desc.Equals(value) Then
               m_tipd_desc = value
               ActualizarInstancia()
            End If
         Else
            m_tipd_desc = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property TIPD_DescC() As String
      Get
         Return m_tipd_descc
      End Get
      Set(ByVal value As String)
         If Not m_tipd_descc Is Nothing Then
            If Not m_tipd_descc.Equals(value) Then
               m_tipd_descc = value
               ActualizarInstancia()
            End If
         Else
            m_tipd_descc = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property ENTC_Ruc() As String
      Get
         Return m_entc_ruc
      End Get
      Set(ByVal value As String)
         If Not m_entc_ruc Is Nothing Then
            If Not m_entc_ruc.Equals(value) Then
               m_entc_ruc = value
               ActualizarInstancia()
            End If
         Else
            m_entc_ruc = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public Property ENTC_RazonSoc() As String
      Get
         Return m_entc_razonsoc
      End Get
      Set(ByVal value As String)
         If Not m_entc_razonsoc Is Nothing Then
            If Not m_entc_razonsoc.Equals(value) Then
               m_entc_razonsoc = value
               ActualizarInstancia()
            End If
         Else
            m_entc_razonsoc = value
            ActualizarInstancia()
         End If
      End Set
   End Property
   Public ReadOnly Property TRAM_Documento() As String
      Get
         m_tram_documento = ""
         If Not IsNothing(m_tipd_descc) Then m_tram_documento += m_tipd_descc + " "
         If Not IsNothing(m_tram_seriedoc) Then m_tram_documento += m_tram_seriedoc + " - "
         If Not IsNothing(m_tram_numdoc) Then m_tram_documento += m_tram_numdoc
         Return m_tram_documento
      End Get
   End Property
#End Region

#Region " Metodos "
   Public Enum Instancia
      Consulta
      Nuevo
      Modificado
      Eliminado
   End Enum
   Public Sub Instanciar(ByVal x_instancia As Instancia)
      Select Case x_instancia
         Case Instancia.Consulta
            m_nuevo = False
            m_modificado = False
            m_eliminado = False
         Case Instancia.Nuevo
            m_nuevo = True
            m_modificado = False
            m_eliminado = False
         Case Instancia.Modificado
            m_nuevo = False
            m_modificado = True
            m_eliminado = False
         Case Instancia.Eliminado
            m_nuevo = False
            m_modificado = False
            m_eliminado = True
      End Select
   End Sub
   Public Sub ActualizarInstancia()
      If Not Nuevo Then
         If Not Eliminado Then
            Instanciar(Instancia.Modificado)
         End If
      End If
   End Sub
#End Region

#Region " Metodos Interfaces "
   Public Function Clone() As Object Implements System.ICloneable.Clone
      Dim _cloneInstance As New ETDC_Tramites()
      _cloneInstance = DirectCast(Me, ETDC_Tramites)
      Return _cloneInstance.MemberwiseClone()
   End Function
#End Region

End Class